import java.util.Date;

public class Car {
    private String lpn;
    public CarParking parking = new CarParking();;


    public String getLpn() {
        return lpn;
    }

    public void setLpn(String lpn) {
        this.lpn = lpn;
    }

    public void enter(int id){
        this.parking.setNo(id);
        long currentDate = System.currentTimeMillis();;
        this.parking.setEnterDate(currentDate);
    }
    public void  out(){
        long currentDate = System.currentTimeMillis();;
        this.parking.setOutdate(currentDate);
        this.parking.setNo(-1);
    }
    public int calculateCost(){
        long start = this.parking.getEnterDate();
        long end = this.parking.getOutdate();
        long hour = (start - end) / (1000*3600);
        if(hour <= 1){
            return 3;
        }else {
            return (int)hour * 2;
        }
    }
    public void isParking(){
        if(this.parking.getNo() != -1) System.out.println("已经停在停车场!");
        else System.out.println("汽车没有在停车场!");
    }

}
